#include <stdio.h>
#include <string.h>

#define STR_SIZE 210

unsigned short lcs[STR_SIZE][2];
char str1[STR_SIZE], str2[STR_SIZE];

int max(int a, int b){
	return a>b?a:b;
}

int main (int argc, const char * argv[]) {
	int len1,len2;
	int i,j;
	while (scanf("%s %s",str1,str2)!=EOF) {
		len1 = strlen(str1);
		len2 = strlen(str2);
		for (i=1; i<=len1; i++) lcs[i][0] = 0;
		for (j=1; j<=len2; j++) {
			for (i=1; i<=len1; i++) {
				if (str1[i-1]==str2[j-1]) lcs[i][1] = 1+lcs[i-1][0];
				else lcs[i][1] = max(lcs[i][0], lcs[i-1][1]);
			}
			for (i=1; i<=len1; i++) lcs[i][0] = lcs[i][1];
		}
		printf("%d\n", lcs[len1][1]);
	}
    return 0;
}